package com.future.tenant.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
import com.future.tenant.db.TenantDatabaseInterceptor;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;

import java.util.Collections;

@AutoConfiguration
public class TenantConfig {

    @Bean
    public TenantLineInnerInterceptor tenantLineInnerInterceptor(MybatisPlusInterceptor mybatisPlusInterceptor) {
        TenantLineInnerInterceptor tenantLineInnerInterceptor = new TenantLineInnerInterceptor(new TenantDatabaseInterceptor());
        mybatisPlusInterceptor.setInterceptors(Collections.singletonList(tenantLineInnerInterceptor));
        return tenantLineInnerInterceptor;
    }
}
